home *** CD-ROM | disk | FTP | other *** search
- Path: bloom-beacon.mit.edu!grapevine.lcs.mit.edu!uhog.mit.edu!europa.eng.gtefsd.com!news.umbc.edu!cs.umd.edu!kong.gsfc.nasa.gov!kong.gsfc.nasa.gov!not-for-mail
- From: dealy@kong.gsfc.nasa.gov (Brian Dealy)
- Newsgroups: comp.windows.x.motif,news.answers,comp.answers
- Subject: Motif FAQ (Part 5 of 5)
- Followup-To: poster
- Date: 14 Apr 1994 15:20:38 -0400
- Organization: NASA/Goddard Space Flight Center
- Lines: 2596
- Approved: news-answers-request@MIT.Edu
- Distribution: inet
- Expires: +1 months
- Message-ID: <2ok526$5et@kong.gsfc.nasa.gov>
- Reply-To: dealy@kong.gsfc.nasa.gov (Brian Dealy)
- NNTP-Posting-Host: kong.gsfc.nasa.gov
- Keywords: FAQ question answer
- Xref: bloom-beacon.mit.edu comp.windows.x.motif:15730 news.answers:18061 comp.answers:4912
-
- Archive-name: motif-faq/part5
- Last-modified: APR 04, 1994
- Version: 3.6
-
-
-
-
-
- -----------------------------------------------------------------------------
- Subject: 126) TOPIC: ICONS
-
- Iconification/de-iconification is a co-operative process between a client and
- a window manager. The relevant standards are set by ICCCM. Mwm is ICCCM
- compliant. The toplevel (non-override-redirect) windows of an application may
- be in three states: WithdrawnState (neither the window nor icon visible),
- NormalState (the window visible) or IconicState (the icon window or pixmap
- visible). This information is contained in the WM_STATE property but ordinary
- clients are not supposed to look at that (its values have not yet been
- standardised). Movement between the three states is standardised by ICCCM.
-
- -----------------------------------------------------------------------------
- Subject: 127) How can I keep track of changes to iconic/normal window state?
-
- Answer: You can look at the WM_STATE property, but this breaks ICCCM
- guidelines. ICCCM compliant window managers will map windows in changing them
- to normal state and unmap them in changing them to iconic state. Look for
- StructureNotify events and check the event type:
-
- XtAddEventHandler (toplevel_widget,
- StructureNotifyMask,
- False,
- StateWatcher,
- (Opaque) NULL);
- ....
- void StateWatcher (w, unused, event)
- Widget w;
- caddr_t unused;
- XEvent *event;
- {
- if (event->type == MapNotify)
- printf ("normal\n");
- else if (event->type == UnmapNotify)
- printf ("iconified\n");
- else printf ("other event\n");
- }
-
-
- If you insist on looking at WM_STATE, here is some code (from Ken Sall) to do
- it:
-
- /*
- ------------------------------------------------------------------
- Try a function such as CheckWinMgrState below which returns one of
- IconicState | NormalState | WithdrawnState | NULL :
- ------------------------------------------------------------------
- */
- #define WM_STATE_ELEMENTS 1
-
- unsigned long *CheckWinMgrState (dpy, window)
- Display *dpy;
- Window window;
- {
- unsigned long *property = NULL;
- unsigned long nitems;
- unsigned long leftover;
- Atom xa_WM_STATE, actual_type;
- int actual_format;
- int status;
-
- xa_WM_STATE = XInternAtom (dpy, "WM_STATE", False);
-
- status = XGetWindowProperty (dpy, window,
- xa_WM_STATE, 0L, WM_STATE_ELEMENTS,
- False, xa_WM_STATE, &actual_type, &actual_format,
- &nitems, &leftover, (unsigned char **)&property);
-
- if ( ! ((status == Success) &&
- (actual_type == xa_WM_STATE) &&
- (nitems == WM_STATE_ELEMENTS)))
- {
- if (property)
- {
- XFree ((char *)property);
- property = NULL;
- }
- }
- return (property);
- } /* end CheckWinMgrState */
-
-
- -----------------------------------------------------------------------------
- Subject: 128) How can I check if my application has come up iconic? I want
- to delay initialisation code and other processing.
-
- Answer: Use XtGetValues and check for the XmNinitialState value of the
- toplevel shell just before XtMainLoop. -- IconicState is iconic, NormalState
- is not iconic.
-
-
-
-
- -----------------------------------------------------------------------------
- Subject: 129) How can I start my application in iconic state?
-
- Answer: From the command line
-
- application -iconic
-
- Using the resource mechanism, set the resource XmNinitialState to IconicState
- of the toplevel shell widget (the one returned from XtInitialise).
-
- -----------------------------------------------------------------------------
- Subject: 130) How can an application iconify itself?
-
- Answer: In R4 and later, use the call XIconifyWindow.
-
- For R3, send an event to the root window with a type of WM_CHANGE_STATE and
- data IconicState.
-
- void
- IconifyMe (dpy, win)
- Display *dpy;
- Window win; /* toplevel window to iconify */
- {
- Atom xa_WM_CHANGE_STATE;
- XClientMessageEvent ev;
-
- xa_WM_CHANGE_STATE = XInternAtom (dpy,
- "WM_CHANGE_STATE", False);
-
- ev.type = ClientMessage;
- ev.display = dpy;
- ev.message_type = xa_WM_CHANGE_STATE;
- ev.format = 32;
- ev.data.l[0] = IconicState;
- ev.window = win;
-
- XSendEvent (dpy,
- RootWindow (dpy, DefaultScreen(dpy)),
- True,
- (SubstructureRedirectMask | SubstructureNotifyMask),
- &ev);
- XFlush (dpy);
- }
-
-
- -----------------------------------------------------------------------------
- Subject: 131) How can an application de-iconify itself?
-
- Answer: XMapWindow (XtDisplay (toplevel_widget), XtWindow (toplevel_widget)).
-
- -----------------------------------------------------------------------------
- Subject: 132) TOPIC: MISCELLANEOUS
-
- -----------------------------------------------------------------------------
- Subject: 133)+ How do I controll the repeat rate on a SUN keyboard ??
-
-
- Answer:
-
- [...]
-
- -ar1 milliseconds
- This option specifies amount of time in milliseconds
- before which a pressed key should begin to
- autorepeat.
-
- -ar2 milliseconds
- This option specifies the interval in milliseconds
- between autorepeats of pressed keys.
-
- Of course this presumes you're using a server based on the MIT sample server.
- submitted by: kaleb@x.org (Kaleb Keithley)
-
- -----------------------------------------------------------------------------
- Subject: 134) How can I identify the children of a manager widget?
-
- Answer: XmNnumChildren (number of widgets in array).
-
- -----------------------------------------------------------------------------
- Subject: 135) How do I tell if a scrolled window's scrollbars are visible?
-
- Answer: Use XtGetValues() to get the scrollbar widget ID's, then use
- XtIsManaged() to see if they are managed (visible).
-
- thanks to Ken Lee, klee@synoptics.com
-
- -----------------------------------------------------------------------------
- Subject: 136) How can I programatically scroll a XmScrolledWindow in
- XmAUTOMATIC mode?
-
- Answer: In Motif 1.2, use XmScrollVisible(). If you're using a scrolled text
- or scrolled list combination widget, use XmTextScroll() or XmListSet*()
- instead.
-
- The Motif manuals specifically forbid manipulating the scrollbars directly,
- but some people have reported success with XmScrollBarSetValues, with the
- "notify" parameter set to "True".
-
- thanks to Ken Lee, klee@synoptics.com
-
- -----------------------------------------------------------------------------
- Subject: 137) What functions can an application use to change the size or
- position of a widget?
-
- Answer: Applications should set the values of the XmNx, XmNy, XmNwidth, and
- XmNheight resources.
-
- Note their
- children, relying instead on their internal layout algorithms. If you really
- want specific positions, you must use a manager widget that allows them, e.g.,
- XmBulletinBoard.
-
- Also note that some manager widgets reject size change requests from their
- children when certain resources are set (e.g., XmNresizable on XmForm).
- Others allow the the children to resize, but clip the results (e.g.,
- XmNallowShellResize on shell widgets). Make sure you have these resources set
- to the policy you want.
-
- Due to bugs, some widgets (third party widgets) do not respond to changes in
- their width and height. Sometimes, you can get them to respond correctly by
- unmanaging them, setting the resources, then managing them again.
-
- Under no circumstances should applications use routines like
- XtConfigureWidget() or XtResizeWidget(). These routines are reserved for
- widget internals and will seriously confuse many widgets. _ thanks to Ken
- Lee, klee@synoptics.com ----------
- -------------------------------------------------------------------
- Subject: 138) What widgets should I use to get the look of push buttons, but
- the behaviour of toggle buttons?
-
- Answer:
- Use the XmToggleButton widget, setting XmNindicatorOn to False and
- XmNshadowThickness to 2.
-
- thanks to Ken Lee, klee@synoptics.com ----------
- -------------------------------------------------------------------
- Subject: 139)+ How do I obtain the size of a unmanaged shell widget?
-
- Answer: In the code below, use getsize() for widgets which have been managed,
- and getsize2() for newly created shell widgets which have not yet been
- managed.
-
- getsize2() takes two widget parameters because popup dialogs etc. _consist_
- of two separate widgets - the parent shell and the child bulletin board, form,
- whatever. This important distinction (somewhat glossed over in the Motif
- manuals) is the cause of a large number of queries in comp.windows.x.motif.
- XmCreate...Dialog() functions return the (bulletin board, form, whatever)
- _child_ of the pair, not the parent shell.
-
- getsize2() takes the _shell_ widget as it's first parameter, and the shell's
- _child_ (the bulletin board, form, whatever) as it's second. Thus, if you are
- using code like widget = XmCreate...Dialog() to create your popup dialogs, use
- code like getsize2(XtParent(widget),widget,&width,&height) to get the width
- and height. If you use e.g. XmCreateDialogShell() or XtCreatePopupShell(),
- then you are creating the the shell widget and it's child explicitly, and can
- just pass them into getsize2() with no problem.
-
- Note: getsize2() calls getsize().
-
- /* getsize(widget,width,height);
- * Widget widget;
- * int *width,*height;
- *
- * returns the width and height of a managed widget */
-
-
-
-
- void getsize(l,w,h) Widget l; int *w,*h; { Dimension w_,h_,b_;
-
- static Arg size_args[] =
- {
- { XmNwidth,0 },
- { XmNheight,0 },
- { XmNborderWidth,0 },
- };
-
- size_args[0].value = (XtArgVal)&w_; size_args[1].value = (XtArgVal)&h_;
- size_args[2].value = (XtArgVal)&b_;
-
- XtGetValues(l,size_args,3);
-
- if (w) *w = w_ + b_; if (h) *h = h_ + b_; } /*
- getsize2(shell,child,width,height);
- * Widget shell,child;
- * int *width,*height;
- *
- * returns the width, height of an unmanaged shell widget */
-
- void getsize2(p,c,w,h) Widget p,c; int *w,*h; { XtSetMappedWhenManaged(p,0);
-
- XtManageChild(c);
-
- getsize(p,w,h);
-
- XtUnmanageChild(c);
-
- XtSetMappedWhenManaged(p,-1); } submitted by: [ Huw Rogers Communications
- Software Engineer, NEC Corporation, Tokyo, Japan ] [ Email:
- rogersh@ccs.mt.nec.co.jp Fax: +81-3-5476-1005 Tel: +81-3-5476-1096 ]
-
- -----------------------------------------------------------------------------
- Subject: 140) Can I use XtAddTimeOut(), XtAddWorkProc(), and XtAddInput()
- with XtAppMainLoop()?
-
- Answer: On many systems, the obsolete XtAdd*() functions are not compatible
- with the XtAppMainLoop(). Instead, you should use newer XtAppAddTimeOut(),
- XtAppAddWorkProc(), and XtAppAddInput() functions with XtAppMainLoop()
-
- thanks to Ken Lee, klee@synoptics.com ----------
- -------------------------------------------------------------------
- Subject: 141) Why does XtGetValues() XmNx and XmNwidth return extremely large
- values.
-
- Answer: You must use the 16 bit "Dimension" and "Position" data types for your
- arguments. If you use 32 bit integers, some implementations will fill the
- remaining 16 bits with invalid data, causing incorrect return values. The
- *Motif Programmer's Manual* and the widget man pages specify the correct data
- type for each resource.
-
- thanks to Ken Lee, klee@synoptics.com ----------
- -------------------------------------------------------------------
- Subject: 142) Can I specify callback functions in resource files?
-
- Answer: To specify callbacks, you must use UIL in addition to or in place of
- resource files. You can, however, specify translations in resource files,
- which give you most of the same functionality as callback functions.
-
- thanks to Ken Lee, klee@synoptics.com ----------
- -------------------------------------------------------------------
- Subject: 143) How do I specify a search path for ".uid" files? Answer: Use
- the UIDPATH environment variable. It is documented on the MrmOpenHierarchy()
- man page.
-
- -----------------------------------------------------------------------------
- Subject: 144) XtGetValues() on XmNx and XmNy of my top level shell don't
- return the correct root window coordinates. How do I compute these?
-
- Answer: XmNx and XmNy are the coordinates relative to your shell's parent
- window, which is usually a window manager's frame window. To translate to the
- root coordinate space, use XtTranslateCoords() or XTranslateCoordinates().
-
- thanks to Ken Lee, klee@synoptics.com ----------
- -------------------------------------------------------------------
- Subject: 145) Can I use XmGetPixmap() with widgets that have non-default
- visual types?
-
- Answer: If you're using a different depth, use XmGetPixmapByDepth() instead.
-
- thanks to Ken Lee, klee@synoptics.com ----------
- -------------------------------------------------------------------
- Subject: 146) How can I determine the item selected in a option menu or a
- RadioBox?
-
- Answer: The value of the XmNmenuHistory resource of the XmRowColumn parent is
- the widget ID of the last selected item. It works the same way for all menus
- and radio boxes. thanks to Ken Lee, klee@synoptics.com
-
- -----------------------------------------------------------------------------
- Subject: 147) What is the matter with Frame in Motif 1.2?
-
- [Last modified: November 92]
-
- Answer: This announcement has been made by OSF:
-
- "IMPORTANT NOTICE
-
- We have discovered two problems in the new 1.2 child alignment resources in
- XmFrame. Because some vendors may have committed, or are soon to commit to
- field releases of Motif 1.2 and 1.2.1, OSF's options for fixing them are
- limited. We are trying to deal with these in a way that does not cause
- hardship for application developers who will develop applications against
- various point versions of Motif. OSF's future actions for correction are
- summarized.
-
- WHAT YOU SHOULD DO AND KNOW
-
- 1. Mark the following change in your documentation.
-
- On page 1-512 of the OSF/Motif Programmer's Reference, change the descriptions
- under XmNchildVerticalAlignment as follows (what follows is the CORRECT
- wording to match the current implementation):
-
- XmALIGNMENT_WIDGET_TOP
- Causes the BOTTOM edge of the title area to align
- vertically with the top shadow of the Frame.
-
- XmALIGNMENT_WIDGET_BOTTOM
- Causes the TOP edge of the title area to align
- vertically with the top shadow of the Frame.
-
- 2. Note the following limitation on resource converters for Motif 1.2 and
- 1.2.1 implementations.
-
- The rep types for XmFrame's XmNentryVerticalAlignment resource were
- incorrected implemented, which means that converters will not work properly.
- The following resource settings will not work from a resource file in 1.2 and
- 1.2.1:
-
- *childVerticalAlignment: alignment_baseline_bottom
- *childVerticalAlignment: alignment_baseline_top
- *childVerticalAlignment: alignment_widget_bottom
- *childVerticalAlignment: alignment_widget_top
-
- If you wish to set these values for these resources (note they are new
- rces in XmFrame) you will have to set them directly in C or
- via uil.
-
- WHAT WE WILL DO
-
- The problem described in note #1 above will not be fixed in the OSF/Motif
- implementation until the next MAJOR release of Motif. At that time we will
- correct the documentation and modify the code to match those new descriptions,
- but we will preserve the existing enumerated values and their behavior for
- backward compatibility for that release.
-
- The fix for the problem described in note #2 will be shipped by OSF in Motif
- 1.2.2.
-
- SUMMARY
-
- We are sorry for any difficulty this causes Motif users. If you have any
- questions or flames (I suppose I deserve it) please send them directly to me.
- We sincerely hope this proactive response is better for our customers than you
- having to figure it out yourselves!
-
- Libby
-
-
- -----------------------------------------------------------------------------
- Subject: 148) What is IMUG and how do I join it?
-
- Answer: IMUG is the International Motif User Group founded by Quest Windows
- Corporation and co-sponsored by FedUNIX. IMUG is a non-profit organization
- working to keep users informed on technical and standards issues, to
- strengthen user groups on a local level, to increase communication among users
- internationally, and to promote the use of an international conference as a
- forum for sharing and learning more about Motif. You can join it by
-
- 1. Pay the annual membership fee of $20 USD directly to IMUG. Contact
-
- IMUG
- 5200 Great America Parkway
- Santa Clara, CA 95054
- (408) 496-1900
- imug@quest.com
-
- 2. Register at the International Motif User Conference, and automatically
- become an IMUG member.
-
- 3. Donate a pd widget, widget tool or widget builder to the IMUG Widget
- Depository and receive a free one year IMUG membership.
-
-
- -----------------------------------------------------------------------------
- Subject: 149) What is the X Professional Organization
-
- [Last modified: JAN 02 1994]
-
- Answer: The X Professional Organization's (XPO) purpose is to provide service
- to the X community. It will serve as an information conduit for professional
- users of X. XPO will participate in X activities, and help keep its members
- informed on X related issues.
-
- http://
- In addition to the communication that professional organizations offer, XPO
- provides these other benefits to members:
-
- * subscription to the The X Resource, a quarterly publication
- by O'Reilly & Associates, Inc.,
-
- * discounts on X related products, 20% off most new books
-
- *** For a sample issue of the newsletter,
- *** email XPO@DELPHI.COM and include your surface address:
-
- * the XPO quarterly newsletter featuring:
- o highlights of conference activities,
- o new product information,
- o articles highlighting the latest innovations in X,
- o feedback from developers and users of X,
- o calendar of activities,
- o forum for X professionals to interact and learn,
- o and much more...
-
- Membership Information:
- Annual pricing information in US dollars.
-
- Associate: Quarterly newsletter
- Regular: Quarterly newsletter + subscription to The X Resource
- Special: Regular + The X Resource supplemental issues
-
- Country Associate Regular Special
- USA $35.00 $100.00 $120.00
- Canada & Mexico $40.00 $105.00 $135.00
- Europe & Africa $45.00 $125.00 $175.00
- Asia & Australia $50.00 $130.00 $185.00
-
-
- Contact: X Professional Organization, Post Office Box 78, Beltsville,
- Maryland, 20704 USA
-
- phone: (301) 681 - 2230
- fax: (410) 465 - 9918, email: XPO@DELPHI.COM
-
- <A HREF= "http://nearnet.gnn.com/gnn/meta/internet/mkt/xpo/profile.html" XPO Company profile </a>
-
-
- -----------------------------------------------------------------------------
- Subject: 150) How do I set the title of a top level window?
-
- [Last modified: September 92]
-
- Answer: Set XmNtitle (and optionally XmNtitleEncoding) for TopLevelShells.
- (Note that this is of type String rather than XmStrin.) Ypu can also set
- XmNiconName if you want its icon to show this title. For XmDialogShells, set
- the XmNdialogTitle of its immediate child, assuming it's a BulletinBoard
- subclass. These can also be set in resource files.
-
-
- -----------------------------------------------------------------------------
- Subject: 151) Can I use editres with Motif?
- [Last modified: January 93]
-
- Answer: It isn't built in to Motif (at 1.2.0), but you can do this in your
- application
-
- extern void _XEditResCheckMessages();
- ...
- XtAddEventHandler(shell_widget, (EventMask)0, True,
- _XEditResCheckMessages, NULL);
-
- once for each shell widget that you want to react to the "click to select
- client" protocol. Then link your client with the R5 libXmu.
-
- David Brooks, OSF
-
- From Marc Quinton (quinton@stna7.stna7.stna.dgac.fr):
-
- With X11R4 see the Editres package which is a port of the X11R5 Editres
- protocol and client. You can find it at :
-
- ftp.stna7.stna.dgac.fr(143.196.9.83):/pub/dist/Editres.tar.Z
-
- -----------------------------------------------------------------------------
- Subject: 152) How can I put decorations on transient windows using olwm?
-
- Answer: From Jean-Philippe Martin-Flatin <syj@ecmwf.co.uk>
-
- /**********************************************************************
- ** WindowDecorations.c
- **
- ** Manages window decorations under the OpenLook window manager (OLWM).
- **
- ** Adapted from a C++ program posted to comp.windows.x.motif by:
- **
- ** +--------------------------------------------------------------+
- ** | Ron Edmark User Interface Group |
- ** | Tel: (408) 980-1500 x282 Integrated Systems, Inc. |
- ** | Internet: edmark@isi.com 3260 Jay St. |
- ** | Voice mail: (408) 980-1590 x282 Santa Clara, CA 95054 |
- ** +--------------------------------------------------------------+
- ***********************************************************************/
-
- #include <X11/X.h>
- #include <X11/Xlib.h>
- #include <X11/Xatom.h>
- #include <X11/Intrinsic.h>
- #include <X11/StringDefs.h>
- #include <X11/Protocols.h>
- #include <Xm/Xm.h>
- #include <Xm/AtomMgr.h>
-
- /*
- ** Decorations for OpenLook:
- ** The caller can OR different mask options to change the frame decoration.
- */
- #define OLWM_Header (long)(1<<0)
- #define OLWM_Resize (long)(1<<1)
- #define OLWM_Close (long)(1<<2)
-
- /*
- ** Prototypes
- */
- static void InstallOLWMAtoms (Widget w);
- static void AddOLWMDialogFrame(Widget widget, long decorationMask);
-
-
- /*
- ** Global variables
- */
- static Atom AtomWinAttr;
- static Atom AtomWTOther;
- static Atom AtomDecor;
- static Atom AtomResize;
- static Atom AtomHeader;
- static Atom AtomClose;
- static int not_installed_yet = TRUE;
-
-
- static void InstallOLWMAtoms(Widget w)
- {
- AtomWinAttr = XInternAtom(XtDisplay(w), "_OL_WIN_ATTR" , FALSE);
- AtomWTOther = XInternAtom(XtDisplay(w), "_OL_WT_OTHER", FALSE);
- AtomDecor = XInternAtom(XtDisplay(w), "_OL_DECOR_ADD", FALSE);
- AtomResize = XInternAtom(XtDisplay(w), "_OL_DECOR_RESIZE", FALSE);
- AtomHeader = XInternAtom(XtDisplay(w), "_OL_DECOR_HEADER", FALSE);
- AtomClose = XInternAtom(XtDisplay(w), "_OL_DECOR_CLOSE", FALSE);
-
- not_installed_yet = FALSE;
- }
-
- static void AddOLWMDialogFrame(Widget widget, long decorationMask)
- {
- Atom winAttrs[2];
- Atom winDecor[3];
- Widget shell = widget;
- Window win;
- int numberOfDecorations = 0;
-
- /*
- ** Make sure atoms for OpenLook are installed only once
- */
- if (not_installed_yet) InstallOLWMAtoms(widget);
-
- while (!XtIsShell(shell)) shell = XtParent(shell);
-
- win = XtWindow(shell);
-
- /*
- ** Tell Open Look that our window is not one of the standard OLWM window ** types. See OLIT Widget Set Programmer's Guide pp.70-73.
- */
-
- winAttrs[0] = AtomWTOther;
-
- XChangeProperty(XtDisplay(shell),
- win,
- AtomWinAttr,
- XA_ATOM,
- 32,
- ce,
- (unsigned char*)winAttrs,
- 1);
-
- /*
- ** Tell Open Look to add some decorations to our window
- */
- numberOfDecorations = 0;
- if (decorationMask & OLWM_Header)
- winDecor[numberOfDecorations++] = AtomHeader;
- if (decorationMask & OLWM_Resize)
- winDecor[numberOfDecorations++] = AtomResize;
- if (decorationMask & OLWM_Close)
- {
- winDecor[numberOfDecorations++] = AtomClose;
-
- /*
- ** If the close button is specified, the header must be
- ** specified. If the header bit is not set, set it.
- */
- if (!(decorationMask & OLWM_Header))
- winDecor[numberOfDecorations++] = AtomHeader;
- }
-
- XChangeProperty(XtDisplay(shell),
- win,
- AtomDecor,
- XA_ATOM,
- 32,
- PropModeReplace,
- (unsigned char*)winDecor,
- numberOfDecorations);
- }
-
-
- /*
- ** Example of use of AddOLWMDialogFrame, with a bit of extra stuff
- */
- void register_dialog_to_WM(Widget shell, XtCallbackProc Cbk_func)
- {
- Atom atom;
-
- /*
- ** Alias the "Close" item in system menu attached to dialog shell
- ** to the activate callback of "Exit" in the menubar
- */
- if (Cbk_func)
- {
- atom = XmInternAtom(XtDisplay(shell),"WM_DELETE_WINDOW",TRUE);
- XmAddWMProtocolCallback(shell,atom, Cbk_func,NULL);
- }
-
- /*
- ** If Motif is the window manager, skip OpenLook specific stuff
- */
- if (XmIsMotifWMRunning(shell)) return;
-
- /*
- ** Register dialog shell to OpenLook.
- **
- ** WARNING: on some systems, adding the "Close" button allows the title
- ** to be properly centered in the title bar. On others, activating
- ** "Close" crashes OpenLook. The reason is not clear yet, but it seems
- ** the first case occurs with OpenWindows 2 while the second occurs with
- ** Openwindows 3. Thus, comment out one of the two following lines as
- ** suitable for your site, and send e-mail to syj@ecmwf.co.uk if you
- ** find out what is going on !
- */
- AddOLWMDialogFrame(shell,(OLWM_Header | OLWM_Resize));
- /* AddOLWMDialogFrame(shell,(OLWM_Header | OLWM_Resize | OLWM_Close)); */
- }
-
-
- -----------------------------------------------------------------------------
- Subject: 153) Why does an augment translation appear to act as replace for
- some widgets? When I use either augment or override translations in
- .Xdefaults it seems to act as replace in both Motif 1.0 and 1.1
-
- Answer: By default, the translation table is NULL. If there is nothing
- specified (either in resource file, or in args), the widget's Initialize
- finds: Oh, there is NULL in translations, lets use our default ones. If,
- however, the translations have become non-NULL, the default translations are
- NOT used at all. Thus, using #augment, #override or a new table has identical
- effect: defines the new translations. The only way you can augment/override
- Motif's default translations is AFTER Initialize, using XtSetValues. Note,
- however, that Motif managers do play with translation tables as well ... so
- that results are not always easy to predict.
-
- From OSF: A number of people have complained about not being able to
- augment/override translations from the .Xdefaults. This is due to the
- complexity of the menu system/keyboard traversal and the necessary
- translations changes required to support the Motif Style Guide in menus. It
- cannot be fixed in a simple way. Fixing it requires re-design of the
- menus/buttons and it is planned to be fixed in 1.2.
-
-
-
-
-
- -----------------------------------------------------------------------------
- Subject: 154) How do you "grey" out a widget so that it cannot be activated?
-
- Answer: Use XtSetSensitive(widget, False). Do not set the XmNsensitive
- resource directly yourself (by XtSetValues) since the widget may need to talk
- to parents first.
-
-
- -----------------------------------------------------------------------------
- Subject: 155) Why doesn't the Help callback work on some widgets?
-
- Answer: If you press the help key the help callback of the widget with the
- keyboard focus is called (not the one containing the mouse). You can't get
- the help callback of a non-keyboard-selectable widget called. To get `context
- sensitive' help on these, you have to find the mouse, associate its position
- with a widget and then do the help.
-
- The X Resource, Issue 6, has an article on implementing context help in
- Motif in this manner, that is, using the mouse position to indicate the
- widget for which context help is desired, as well as using resources to
- specify the help. Example source code is available at
-
- ftp.uu.net:/published/oreilly/xresource/helpdemo.tar.Z
-
- The demo program lets you toggle between using the method described in
- the article and XmTrackingLocate() for comparision purposes.
-
- contributed by: Jay Schmidgall jay@vnet.ibm.com (author of the article
- mentioned above) --
-
-
-
- -----------------------------------------------------------------------------
- Subject: 156) Where can I get a Table widget?
-
- [Last modified: December 92]
-
- Answer: Send email to Kee Hinckley (nazgul@alfalfa.com) asking for a copy of
- his table widget. The Widget Creation Library also has one. See under Motif
- prototyping tools for the contact.
-
- Expert Database Systems, Inc., 377 Rector Place, Suite 3L New York, NY 10280.
- Phone: (212) 783-6981 has a very comprehensive table widget that uses both
- motif scrollbars or a "virtual" scrollbar showing a miniature version of the
- entire spreadsheet. Allows for different width columns, changing colors in
- each cell. Only one X-Window is used so as to reduce the amount of system
- resources used. Contact Ken Jones email: ken@mr_magoo.sbi.com)
-
-
- -----------------------------------------------------------------------------
- Subject: 157) Has anyone done a bar graph widget?
- [Last modified: September 92]
-
- Answer: You can fake one by using for each bar a scroll bar or even a label
- which changes in size, put inside a container of some kind.
-
- Try the StripChart widget in the Athena widget set. Set the XtNupdate resource
- to 0 to keep it from automatically updating.
-
- The comp.windows.x FAQ mentions a bar graph widget.
-
- Expert Database Systems, Inc. sells a bar graph widget as well as a multi-
- line graph with automatic scaling, a 3-D surface graph, and a high/Low graph
- with two lines for moving averages. Contact Ken Jones Expert Database
- Systems, Inc., 377 Rector Place, Suite 3L New York, NY 10280. Phone: (212)
- 783-6981
-
-
- The Xtra XWidget library contains a set of widgets that are subclassed from
- and compatible with either OSF/Motif or OLIT widgets. The library includes
- widgets that implement the following:
-
- Spreadsheet
- Bar Graph
- Stacked Bar Graph
- Line Graph
- Pie Chart
- XY Plot
- Hypertext
- Hypertext based Help System
- Entry Form with type checking
-
- Contact Graphical Software Technology at 310-328-9338 (info@gst.com) for
- information.
-
- The XRT/graph widget, available for Motif, XView and OLIT, displays X-Y plots,
- bar and pie charts, and supports user-feedback, fast updates and PostScript
- output. Contact KL Group Inc. at 416-594-1026 (xrt_info%klg@uunet.ca)
-
- The product Xmath, made by Integrated Systems Inc. is a product which has
- interactive 2d and 3d graphics for bar,strip,line,symbol,
- surface,contour,etc... that costs $2500.00 for commercial use and a mere
- $250.00 for university use that also has complete numerics capabilities, an
- easy to use debugger, a complete high level language, a spreadsheet, a motif
- gui access capability, and much more all created on top of motif.
-
- You can either email to xmath-info@isi.com or call (408)980-1500.
-
- Digital Equipment Corporation (DEC) provides the following product NetEd: "The
- network editor widget is a Motif toolkit conforming widget that applications
- aphically in the form of
- networks or graphs. The network editor supports interactive or application-
- controlled creation and editing of directed graphs or networks."
-
-
- ACE/gr is an X based XY plotting tool implemented with a point 'n click
- paradigm. A few of its features are:
-
- * Plots up to 10 graphs with 30 data sets per graph.
- * Data read from files and/or pipes.
- * Graph types XY, log-linear, linear-log, log-log, bar,
- stacked bar charts.
-
- it is available from
-
- ftp.ccalmr.ogi.edu (presently amb4.ccalmr.ogi.edu)
-
- with IP address 129.95.72.34. The XView version (xvgr) will be found in
- /CCALMR/pub/acegr/xvgr-2.09.tar.Z and the Motif version (xmgr) in
- /CCALMR/pub/acegr/xmgr-2.09.tar.Z. Comments, suggestions, bug reports to
- pturner@amb4.ccalmr.ogi.edu (if mail fails, try pturner@ese.ogi.edu). Due to
- time constraints, replies will be few and far between.
-
-
-
- -----------------------------------------------------------------------------
- Subject: 158) Does anyone know of a source code of a graph widget where you
- can add vertices and edges and get an automated updating?
-
- [Last modified: March 93]
-
- Answer: The XUG FAQ in comp.windows.x includes information on graph display
- widgets. There is also an implementation in the Asente/Swick book.
-
- From Martin Janzen: "You could have a look at DataViews, from V.I.
- Corporation. This package is used mainly to display a variety of graph
- drawings (eg. bar, line, pie, high/low, and other charts), and to update
- the graphs as information is received from "data sources" such as files,
- processes (through pipes), or devices.
-
- However, it also provides "node" and "edge" objects which can be used
- when working with network graphs. The DV-Tools function library
- provides routines which traverse a graph, count visits to each node or
- edge, mark nodes or edges of interest, and so on. A node or edge object
- can have an associated "geometry object" (such as a symbol or a line),
- which represents that node or edge.
-
- Drawbacks: There's no automatic positioning algorithm; when you add a
- node or edge, you have to create and position its geometry object
- yourself. Also, this isn't a set of add-on widgets; you can either have
- DataViews create an X window (ie. a separate shell), or you can create
- your own XmDrawingArea and use DataViews to update its window when
- expose events are received. Finally, the package is quite expensive,
- and there is a run-time charge.
-
- The vendor's address is:
- V.I. Corporation,
- 47 Pleasant Street,
- Northampton, MA 01060,
- Email: vi@vicorp.com, Phone: (413) 586-4144, Fax: (413) 584-2649
-
- or
-
- V.I. Corporation (Europe) Ltd.,
- First Base, Beacontree Plaza,
- Gillette Way, Email: viesales@eurovi.uucp
- Reading, Berkshire RG2 0BP"
- Phone: +44 734 756010, Fax: +44 734 756104
-
- From Craig Timmerman: Just wanted others to know that there is a third
- competitor in what may be come a big market for generic APIs. The product is
- called Open Interface and Neuron Data is the vendor. Neuron has added some
- extra, more complex widgets to their set. The two most notable are a table
- and network widget. [...] I believe that the network widget got its name from
- its ability to display expert system networks that Neuron's AI tools needed.
- It would be more aptly named the graph widget. It can display and manipulate
- graphs of various types (trees, directed graphs, etc). Contact is
-
- Neuron Data
- 156 University Avenue
- Palo Alto, CA 94301
- (415) 321-4488
-
-
- prism!gt3273b@gatech.edu (RENALDS,ANDREW THEODORE) posted a set of public
- domain routines for graph drawing. Contact him for a later set.
-
- From Ramon Santiago (santiago@fgssu1.fgs.slb.com): HP has released source code
- for XmGraph and XmArc, part of the InterWorks library, which does exactly
- this. The sources can be obtained by contacting Dave Shaw,
- librarian@iworks.ecn.uiowa.edu. A few trivial source code changes need to be
- made to get these widgets to compile under Motif 1.2.
-
- Free DAG - directed acyclic graph drawing software in motif environment is
- available. Please send a note to address below if you want it:
-
- Budak Arpinar, TUBITAK Software Research & Development Center, Ankara,
- TURKIYE, E-mail : C51881@TRMETU.BITNET
-
-
-
- -----------------------------------------------------------------------------
- Subject: 159)+ Is there a help system available, such as in Windows 3? Or any
- Motif based hypertext system.
-
- [Last modified: apr 94]
-
- Answer:
-
- HTML Widget from NCSA:
-
- The NCSA Mosaic for X package contains a html widget which is freely available
- and is the main vehicle for viewing html documents in the Mosaic program. It
- has callbacks for anchor hits, selections, etc and many many resources for
- customizing the viewing area of your hypertext documents.
-
- GWHIS:
-
- There is a new product from Quadralay Corporation, called the Global-Wide Help
- & Information Systems (GWHIS).
-
- from a press release: AUSTIN, TX (March 3, 1994) Quadralay Corporation today
- announced its newest software development tool, Global Wide Help & Information
- System (GWHIS). GWHIS allows third party application developers to add online
- documentation and context sensitive help to their applications like never
- before. This documentation may consist of plain text, rich format text,
- hypertext, images, audio, and/or video animation and may easily be distributed
- either locally or over a wide area network such as the Internet.
-
- GWHIS consists of two primary components. An application programming
- interface (API), and a hypermedia viewer (based on technology licensed from
- the NCSA Mosaic project). Several ancillary conversion programs are also
- available allowing end users to easily convert existing documentation into
- GWHIS' native HTML format.
-
- GWHIS is available on the following platforms: SPARC SunOS 4.1.x, SPARC
- Solaris 2.x, INTEL SCO Open Desktop, INTEL Solaris 2.x, HP 9000/700, and the
- RS/6000. Support for additional platforms (including MS Windows and Macintosh)
- is under consideration. Fully functional evaluation copies of this software
- are available upon request or via anonymous ftp from ftp.quadralay.com.
-
- Brian Combs Quadralay Corporation combs@quadralay.com
-
-
-
- Bristol Technology have a hypertext system HyperHelp with the look-and-feel of
- either Motif or OpenLook. It should be available from january 31, 1992.
- Contact
-
- Bristol Technology Inc.
- 898 Ethan Allen Highway
- Ridgefield, CT 06877
- 203-438-6969 (phone)
- 203-438-5013 (fax)
- uunet.uu.net!bristol!keith
-
- Demos are available by anonymous ftp from ftp.uu.net (137.39.1.9) in the
- vendor/Bristol/HyperHelp as files sun.motif.tar.Z and hp.tar.Z.
-
- There was a posting of a motif hypertext-widget to comp.sources.x (Author:
- B.Raoult ( mab@ecmwf.co.uk ) ). It had the facility to read in helptext from
- a file.
-
- From Francois Felix Ingrand (felix@idefix.laas.fr): I have translated the Info
- AW (originally written by Jordan Hubbard) to Motif. It is a Widget to browse
- Info files (format used by GNU for their various documentations). I use it as
- the help system of various tool I wrote. It is available on laas.laas.fr
- (140.93.0.15) in /pub/prs/xinfo-motif.tar.Z
-
- Form Scott Raney (raney@metacard.com) MetaCard is a commercial package that
- can be used to implement hypertext help. The text fields support multiple
- typefaces, sizes, styles, colors, subscript/superscript, and hypertext links.
- It has a Motif interface, and a template for calling it from an Xt/Motif
- application is included. You can FTP a save-disabled distribution from
- ftp.metacard.com or from world.std.com. For more info, email to
- info@metacard.com.
-
-
- The Motifation GbR also provides a hypertext-helpsystem named 'XpgHelp'.
- (Motif look-and-feel / features like those known from MS Windows Help ) For a
- free demo or more information send email either to griebel@uni-paderborn.d e
- or contact the distributor:
-
- PEM GmbH,
- Vaihinger Strasse 49,
- 7000 Stuttgart 80,
- Germany,
- +49 (0) 711 713045 (phone),
- +49 (0) 711 713047 (fax),
- asien@pem-stuttgart.de
-
- XpgHelp has nearly the same features like HyperHelp: (multiple fonts, graphics
- in b&w and color, different styles, tabs, links, short links, notepad, ...)
-
- The Interface Builder MOTIFATION uses XpgHelp as its hypertext helpsystem.
-
-
-
- -----------------------------------------------------------------------------
- Subject: 160) Can I specify a widget in a resource file?
-
- Answer: This answer, which uses the Xmu library, is due to David Elliott. If
- the converter is added, then the name of a widget (a string) can be used in
- resource files, and will be converted to the appropriate widget.
-
- This code, which was basically stolen from the Athena Form widget, adds a
- String to Widget converter. I wrote it as a general routine that I call at
- the beginning of all of my programs, and made it so I could add other
- converters as needed (like String to Unit Type ;-).
-
- #include <X11/Intrinsic.h>
- #include <X11/StringDefs.h>
- #include <Xm/Xm.h>
- #include <X11/Xmu/Converters.h>
- #include <X11/IntrinsicP.h>
- #include <X11/CoreP.h>
-
- void
- setupConverters()
- {
- static XtConvertArgRec parentCvtArgs[] = {
- {XtBaseOffset, (caddr_t)XtOffset(Widget, core.parent),
- sizeof(Widget)}
- };
-
- XtAddConverter(XmRString, XmRWindow, XmuCvtStringToWidget,
- parentCvtArgs, XtNumber(parentCvtArgs));
- }
-
-
-
- -----------------------------------------------------------------------------
- Subject: 161) Why are only some of my translations are being installed? I
- have a translation table like the following, but only the first ones are
- getting installed and the rest are ignored.
-
- *Text.translations: #override \
- Ctrl<Key>a: beginning-of-line() \n\
- Ctrl<Key>e: end-of-line() \n\
- Ctrl<Key>f: forward-character() \n\
-
-
- Answer: Most likely, you have a space at the end of one of the lines (the
- first in this case).
-
- Ctrl<Key>a: beginning-of-line() \n\
- ^ space here
-
- The second backslash in each line is there to protect the real newline
- character and so you must not follow it with anything other than the newline
- itself. Otherwise it acts as the end of the resource definition and the
- remaining lines are not added.
-
-
- -----------------------------------------------------------------------------
- Subject: 162) Where can I get the PanHandler code?
-
- Answer: It is available by email from Chuck Ocheret: chuck@IMSI.COM.
-
- -----------------------------------------------------------------------------
- Subject: 163) What are these passive grab warnings? When I destroy certain
- widgets I get a stream of messages
-
- Warning: Attempt to remove non-existant passive grab
-
-
- Answer: They are meaningless, and you want to ignore them. Do this (from Kee
- Hinckley) by installing an XtWarning handler that explicitly looks for them
- and discards them:
-
- static void xtWarnCB(String message) {
- if (asi_strstr(message, "non-existant passive grab", TRUE)) return;
- ...
-
- They come from Xt, and (W. Scott Meeks): "it's something that the designers of
- Xt decided the toolkit should do. Unfortunately, Motif winds up putting
- passive grabs all over the place for the menu system. On the one hand, we
- want to remove all these grabs when menus get destroyed so that they don't
- leak memory; on the other hand, it's almost impossible to keep track of all
- the grabs, so we have a conservative strategy of ungrabbing any place where a
- grab could have been made and we don't explicitly know that there is no grab.
- The unfortunate side effect is the little passive grab warning messages.
- We're trying to clean these up where possible, but there are some new places
- where the warning is generated. Until we get this completely cleaned up (1.2
- maybe), your best bet is probably to use a warning handler."
-
- -----------------------------------------------------------------------------
- Subject: 164) How do I have more buttons than three in a box? I want to have
- something like a MessageBox (or other widget) with more than three buttons,
- but with the same nice appearance.
-
- [Last modified: May 93]
-
- Answer: The Motif 1.2 MessageBox widget allows extra buttons to be added after
- the OK button. Just create the extra buttons as children of the MessageBox.
- Similarly with the SelectionBox.
-
- Pre-Motif 1.2, you have to do one of the following methods.
-
- A SelectionBox is created with four buttons, but the fourth (the Apply button)
- is unmanaged. To manage it get its widget ID via
- XmSelectionBoxGetChild(parent, XmDIALOG_APPLY_BUTTON) and then XtManage it.
- Unmanage all of the other bits in the SelectionBox that you don't want. If
- you want more than four buttons, try two SelectionBoxes (or similar) together
- in a container, where all of the unwanted parts of the widgets are unmanaged.
-
- Alternatively, build your own dialog:
-
- /* Written by Dan Heller. Copyright 1991, O'Reilly && Associates.
- * This program is freely distributable without licensing fees and
- * is provided without guarantee or warranty expressed or implied.
- * This program is -not- in the public domain. This program is
- * taken from the Motif Programming Manual, O'Reilly Volume 6.
- */
-
- /* action_area.c -- demonstrate how CreateActionArea() can be used
- * in a real application. Create what would otherwise be identified
- * as a PromptDialog, only this is of our own creation. As such,
- * we provide a TextField widget for input. When the user presses
- * Return, the Ok button is activated.
- */
- #include <Xm/DialogS.h>
- #include <Xm/PushBG.h>
- #include <Xm/PushB.h>
- #include <Xm/LabelG.h>
- #include <Xm/PanedW.h>
- #include <Xm/Form.h>
- #include <Xm/RowColumn.h>
- #include <Xm/TextF.h>
-
- typedef struct {
- char *label;
- void (*callback)();
- caddr_t data;
- } ActionAreaItem;
-
- static void
- do_dialog(), close_dialog(), activate_cb(),
- ok_pushed(), cancel_pushed(), help();
-
- main(argc, argv)
- int argc;
- char *argv[];
- {
- Widget toplevel, button;
- XtAppContext app;
-
- toplevel = XtVaAppInitialize(&app, "Demos",
- NULL, 0, &argc, argv, NULL, NULL);
-
- button = XtVaCreateManagedWidget("Push Me",
- xmPushButtonWidgetClass, toplevel, NULL);
- XtAddCallback(button, XmNactivateCallback, do_dialog, NULL);
-
- XtRealizeWidget(toplevel);
- XtAppMainLoop(app);
- }
-
- /* callback routine for "Push Me" button. Actually, this represents
- * a function that could be invoked by any arbitrary callback. Here,
- * we demonstrate how one can build a standard customized dialog box.
- * The control area is created here and the action area is created in
- * a separate, generic routine: CreateActionArea().
- */
- static void
- do_dialog(w, file)
- Widget w; /* will act as dialog's parent */
- char *file;
- {
- Widget dialog, pane, rc, label, text_w, action_a;
- XmString string;
- extern Widget CreateActionArea();
- Arg args[10];
- static ActionAreaItem action_items[] = {
- { "Ok", ok_pushed, NULL },
- { "Cancel", cancel_pushed, NULL },
- { "Close", close_dialog, NULL },
- { "Help", help, "Help Button" },
- };
-
- /* The DialogShell is the Shell for this dialog. Set it up so
- * that the "Close" button in the window manager's system menu
- * destroys the shell (it only unmaps it by default).
- */
- dialog = XtVaCreatePopupShell("dialog",
- xmDialogShellWidgetClass, XtParent(w),
- XmNtitle, "Dialog Shell", /* give arbitrary title in wm */
- XmNdeleteResponse, XmDESTROY, /* system menu "Close" action */
- NULL);
-
- /* now that the dialog is created, set the Close button's
- * client data, so close_dialog() will know what to destroy.
- */
- action_items[2].data = (caddr_t)dialog;
-
- /* Create the paned window as a child of the dialog. This will
- * contain the control area (a Form widget) and the action area
- * (created by CreateActionArea() using the action_items above).
- */
- pane = XtVaCreateWidget("pane", xmPanedWindowWidgetClass, dialog,
- 1,
- XmNsashHeight, 1,
- NULL);
-
- /* create the control area (Form) which contains a
- * Label gadget and a List widget.
- */
- rc = XtVaCreateWidget("control_area", xmRowColumnWidgetClass, pane, NULL);
- string = XmStringCreateSimple("Type Something:");
- XtVaCreateManagedWidget("label", xmLabelGadgetClass, rc,
- XmNlabelString, string,
- XmNleftAttachment, XmATTACH_FORM,
- XmNtopAttachment, XmATTACH_FORM,
- NULL);
- XmStringFree(string);
-
- text_w = XtVaCreateManagedWidget("text-field",
- xmTextFieldWidgetClass, rc, NULL);
-
- /* RowColumn is full -- now manage */
- XtManageChild(rc);
-
- /* Set the client data "Ok" and "Cancel" button's callbacks. */
- action_items[0].data = (caddr_t)text_w;
- action_items[1].data = (caddr_t)text_w;
-
- /* Create the action area -- we don't need the widget it returns. */
- action_a = CreateActionArea(pane, action_items, XtNumber(action_items));
-
- /* callback for Return in TextField. Use action_a as client data */
- XtAddCallback(text_w, XmNactivateCallback, activate_cb, action_a);
-
- XtManageChild(pane);
- XtPopup(dialog, XtGrabNone);
- }
-
- /*--------------*/
- /* The next four functions are the callback routines for the buttons
- * in the action area for the dialog created above. Again, they are
- * simple examples, yet they demonstrate the fundamental design approach.
- */
- static void
- close_dialog(w, shell)
- Widget w, shell;
- {
- XtDestroyWidget(shell);
- }
-
- /* The "ok" button was pushed or the user pressed Return */
- static void
- ok_pushed(w, text_w, cbs)
- Widget w, text_w; /* the text widget is the client data */
- XmAnyCallbackStruct *cbs;
- {
- char *text = XmTextFieldGetString(text_w);
-
- printf("String = %s0, text);
- XtFree(text);
- }
-
- static void
- cancel_pushed(w, text_w, cbs)
- Widget w, text_w; /* the text field is the client data */
- XmAnyCallbackStruct *cbs;
- {
- /* cancel the whole operation; reset to NULL. */
- XmTextFieldSetString(text_w, "");
- }
-
- static void
- help(w, string)
- Widget w;
- String string;
- {
- puts(string);
- }
- /*--------------*/
-
- /* When Return is pressed in TextField widget, respond by getting
- * the designated "default button" in the action area and activate
- * it as if the user had selected it.
- */
- static void
- activate_cb(text_w, client_data, cbs)
- Widget text_w; /* user pressed Return in this widget */
- XtPointer client_data; /* action_area passed as client data */
- XmAnyCallbackStruct *cbs; /* borrow the "event" field from this */
- {
- Widget dflt, action_area = (Widget)client_data;
-
- XtVaGetValues(action_area, XmNdefaultButton, &dflt, NULL);
- if (dflt) /* sanity check -- this better work */
- /* make the default button think it got pushed. This causes
- * "ok_pushed" to be called, but XtCallActionProc() causes
- * the button appear to be activated as if the user selected it.
- */
- XtCallActionProc(dflt, "ArmAndActivate", cbs->event, NULL, 0);
- }
-
- #define TIGHTNESS 20
-
- Widget
- CreateActionArea(parent, actions, num_actions)
- Widget parent;
- ActionAreaItem *actions;
- int num_actions;
- {
- Widget action_area, widget;
- int i;
-
- action_area = XtVaCreateWidget("action_area", xmFormWidgetClass, parent,
- XmNfractionBase, TIGHTNESS*num_actions - 1,
- XmNleftOffset, 10,
- XmNrightOffset, 10,
- NULL);
-
- for (i = 0; i < num_actions; i++) {
- widget = XtVaCreateManagedWidget(actions[i].label,
- xmPushButtonWidgetClass, action_area,
- XmNleftAttachment, i? XmATTACH_POSITION : XmATTACH_FORM,
- XmNleftPosition, TIGHTNESS*i,
- XmNtopAttachment, XmATTACH_FORM,
- XmNbottomAttachment, XmATTACH_FORM,
- XmNrightAttachment,
- i != num_actions-1? XmATTACH_POSITION : XmATTACH_FORM,
- XmNrightPosition, TIGHTNESS*i + (TIGHTNESS-1),
- XmNshowAsDefault, i == 0,
- XmNdefaultButtonShadowThickness, 1,
- NULL);
- if (actions[i].callback)
- XtAddCallback(widget, XmNactivateCallback,
- actions[i].callback, actions[i].data);
- if (i == 0) {
- /* Set the action_area's default button to the first widget
- * created (or, make the index a parameter to the function
- * or have it be part of the data structure). Also, set the
- * pane window constraint for max and min heights so this
- * particular pane in the PanedWindow is not resizable.
- */
- Dimension height, h;
- XtVaGetValues(action_area, XmNmarginHeight, &h, NULL);
- XtVaGetValues(widget, XmNheight, &height, NULL);
- height += 2 * h;
- XtVaSetValues(action_area,
- XmNdefaultButton, widget,
- XmNpaneMaximum, height,
- XmNpaneMinimum, height,
- NULL);
- }
- }
-
- XtManageChild(action_area);
-
- return action_area;
- }
-
-
-
- -----------------------------------------------------------------------------
- Subject: 165) How do I create a "busy working cursor"?
-
- Answer: - in Baudouin's code (following), the idea is to keep in an array an
- up-to-date list of all shells used in the application, and set for all of them
- the cursor to a watch or to the default cursor, with the 2 functions provided.
-
- - in Dan Heller's code (later), the idea is to turn on the watch cursor for
- the top-level shell only, popup a working window to possibly abort the
- callback, and manage some expose events during the callback.
-
- - in the FAQ for comp.windows.x (#113), the idea is to bring a large window on
- top of the application, hide all windows below it, and turn on the watch
- cursor on this large window. Unmapping the large window resets the default
- cursor, mapping it turns on the watch cursor.
-
- From Baudouin Raoult (mab@ecmwf.co.uk)
-
- void my_SetWatchCursor(w)
- Widget w;
- {
- static Cursor watch = NULL;
-
- if(!watch)
- watch = XCreateFontCursor(XtDisplay(w),XC_watch);
-
- XDefineCursor(XtDisplay(w),XtWindow(w),watch);
- XmUpdateDisplay(w);
- }
-
- void my_ResetCursor(w)
- Widget w;
- {
- XUndefineCursor(XtDisplay(w),XtWindow(w));
- XmUpdateDisplay(w);
- }
-
-
- Answer: A solution with lots of bells and whistles is
-
- /* Written by Dan Heller. Copyright 1991, O'Reilly && Associates.
- * This program is freely distributable without licensing fees and
- * is provided without guarantee or warrantee expressed or implied.
- * This program is -not- in the public domain.
- */
-
- /* busy.c -- demonstrate how to use a WorkingDialog and to process
- * only "important" events. e.g., those that may interrupt the
- * task or to repaint widgets for exposure. Set up a simple shell
- * and a widget that, when pressed, immediately goes into its own
- * loop. First, "lock" the shell so that a timeout cursor is set on
- * the shell and pop up a WorkingDialog. Then enter loop ... sleep
- * for one second ten times, checking between each interval to see
- * if the user clicked the Stop button or if any widgets need to be
- * refreshed. Ignore all other events.
- *
- * main() and get_busy() are stubs that would be replaced by a real
- * application; all other functions can be used "as is."
- */
- #include <Xm/MessageB.h>
- #include <Xm/PushB.h>
- #include <X11/cursorfont.h>
-
- Widget shell;
- void TimeoutCursors();
- Boolean CheckForInterrupt();
-
- main(argc, argv)
- int argc;
- char *argv[];
- {
- XtAppContext app;
- Widget button;
- XmString label;
- void get_busy();
-
- shell = XtVaAppInitialize(&app, "Demos",
- NULL, 0, &argc, argv, NULL, NULL);
-
- label = XmStringCreateSimple(
- "Boy, is *this* going to take a long time.");
- button = XtVaCreateManagedWidget("button",
- xmPushButtonWidgetClass, shell,
- XmNlabelString, label,
- NULL);
- XmStringFree(label);
- XtAddCallback(button, XmNactivateCallback, get_busy, argv[1]);
-
- XtRealizeWidget(shell);
- XtAppMainLoop(app);
- }
-
- void
- get_busy(widget)
- Widget widget;
- {
- int n;
-
- TimeoutCursors(True, True);
- for (n = 0; n < 10; n++) {
- ;
- if (CheckForInterrupt()) {
- puts("Interrupt!");
- break;
- }
- }
- if (n == 10)
- puts("done.");
- TimeoutCursors(False, NULL);
- }
-
- /* The interesting part of the program -- extract and use at will */
- static Boolean stopped; /* True when user wants to stop processing */
- static Widget dialog; /* WorkingDialog displayed when timed out */
-
- /* timeout_cursors() turns on the "watch" cursor over the application
- * to provide feedback for the user that he's going to be waiting
- * a while before he can interact with the appliation again.
- */
- void
- TimeoutCursors(on, interruptable)
- int on, interruptable;
- {
- static int locked;
- static Cursor cursor;
- extern Widget shell;
- XSetWindowAttributes attrs;
- Display *dpy = XtDisplay(shell);
- XEvent event;
- Arg args[1];
- XmString str;
- extern void stop();
-
- /* "locked" keeps track if we've already called the function.
- * This allows recursion and is necessary for most situations.
- */
- on? locked++ : locked--;
- if (locked > 1 || locked == 1 && on == 0)
- return; /* already locked and we're not unlocking */
-
- stopped = False; /* doesn't matter at this point; initialize */
- if (!cursor) /* make sure the timeout cursor is initialized */
- cursor = XCreateFontCursor(dpy, XC_watch);
-
- /* if "on" is true, then turn on watch cursor, otherwise, return
- * the shell's cursor to normal.
- */
- attrs.cursor = on? cursor : None;
-
- /* change the main application shell's cursor to be the timeout
- * cursor (or to reset it to normal). If other shells exist in
- * this application, they will have to be listed here in order
- * for them to have timeout cursors too.
- */
- XChangeWindowAttributes(dpy, XtWindow(shell), CWCursor, &attrs);
-
- XFlush(dpy);
-
- if (on) {
- /* we're timing out, put up a WorkingDialog. If the process
- * is interruptable, allow a "Stop" button. Otherwise, remove
- * all actions so the user can't stop the processing.
- */
- str = XmStringCreateSimple("Busy. Please Wait.");
- XtSetArg(args[0], XmNmessageString, str);
- dialog = XmCreateWorkingDialog(shell, "Busy", args, 1);
- XmStringFree(str);
- XtUnmanageChild(
- XmMessageBoxGetChild(dialog, XmDIALOG_OK_BUTTON));
- if (interruptable) {
- str = XmStringCreateSimple("Stop");
- XtVaSetValues(dialog, XmNcancelLabelString, str, NULL);
- XmStringFree(str);
- XtAddCallback(dialog, XmNcancelCallback, stop, NULL);
- } else
- XtUnmanageChild(
- XmMessageBoxGetChild(dialog, XmDIALOG_CANCEL_BUTTON));
- XtUnmanageChild(
- XmMessageBoxGetChild(dialog, XmDIALOG_HELP_BUTTON));
- XtManageChild(dialog);
- } else {
- /* get rid of all button and keyboard events that occured
- * during the time out. The user shouldn't have done anything
- * during this time, so flush for button and keypress events.
- * KeyRelease events are not discarded because accelerators
- * require the corresponding release event before normal input
- * can continue.
- */
- while (XCheckMaskEvent(dpy,
- ButtonPressMask | ButtonReleaseMask | ButtonMotionMask
- | PointerMotionMask | KeyPressMask, &event)) {
- /* do nothing */;
- }
- XtDestroyWidget(dialog);
- }
- }
-
- /* User Pressed the "Stop" button in dialog. */
- void
- stop(dialog)
- Widget dialog;
- {
- stopped = True;
- }
-
- Boolean
- CheckForInterrupt()
- {
- extern Widget shell;
- Display *dpy = XtDisplay(shell);
- Window win = XtWindow(dialog);
- XEvent event;
-
- /* Make sure all our requests get to the server */
- XFlush(dpy);
-
- /* Let motif process all pending exposure events for us. */
- XmUpdateDisplay(shell);
-
- /* Check the event loop for events in the dialog ("Stop"?) */
- while (XCheckMaskEvent(dpy,
- ButtonPressMask | ButtonReleaseMask | ButtonMotionMask |
- PointerMotionMask | KeyPressMask | KeyReleaseMask,
- &event)) {
- /* got an "interesting" event. */
- if (event.xany.window == win)
- XtDispatchEvent(&event); /* it's in our dialog.. */
- else /* uninteresting event--throw it away and sound bell */
- XBell(dpy, 50);
- }
- return stopped;
- }
-
-
- -----------------------------------------------------------------------------
- Subject: 166) Can I use the hourglass that mwm uses?
-
- [Last modified: March 93]
-
- Answer: The hourglass used by mwm is hard-coded into code that is subject to
- OSF copyright. In Motif 1.2 though, the bitmaps for this and other things
- (information, no_enter, question, warning, working) were made available. The
- install process will probably add them to /usr/include/X11/bitmaps.
- Otherwise, just use the watch cursor XC_watch of the previous question,
- because that has the same semantics.
-
-
-
- -----------------------------------------------------------------------------
- Subject: 167) What order should the libraries be linked in?
-
- [Last modified: August 92]
-
- Answer: At link time, use the library order -lXm -lXt -lX11. There are two
- reasons for this (dbrooks@osf.org):
-
- On most systems, the order matters because the linker won't re-scan a library
- once it is done with it. Thus any references to Xlib calls from Xm will
- probably be unresolved.
-
- The [other] problem is that there are two VendorShell widgets. A dummy is
- provided in the Xt library, but a widget set will rely on its own being
- referenced. If you mention Xt first, the linker will choose the wrong one.
-
- Motif code will wrongly assume the Motif VendorShell has been class-
- initialized [and will probably crash].
- Xaw has a similar problem, but a softer landing; it only complains about
- unregistered converters.
-
-
- -----------------------------------------------------------------------------
- Subject: 168) How do I use xmkmf for Motif clients?
-
- [Last modified: October 1992]
-
- Answer: This advice comes from dbrooks@osf.org:
-
- There are a number of intractable problems with using X configuration files
- and xmkmf, while trying to make it easy to build Motif. Not the least of
- these, but one I've never heard mentioned yet, is that the rules for
- contructing the names of shared library macros are machine-dependent, and in
- the various xxxLib.tmpl files. Do we edit all those files to add definitions
- for XMLIB, DEPXMLIB, etc., or do we put a maze of #ifdefs into the Motif.tmpl
- file?
-
- Please note that, if you install Motif, it overwrites your installed
- Imake.tmpl with one that includes Motif.tmpl and Motif.rules.
-
- With those caveats, I think the following guidelines will help.
-
- David Brooks OSF
-
- Clients in the X11R5 release use the xmkmf command to build Makefiles. In
- general, the xmkmf command cannot be used for Motif clients, because of the
- need to consider the UseInstalledMotif flag separately. Since xmkmf is a
- simple script that calls imake, it is easy to construct the proper call to
- imake using the following rules.
-
- In the following, replace {MTOP} by the toplevel directory with the Motif
- source tree, and {XTOP} by the toplevel ("mit") directory with the X source.
- It is assumed that the directory containing your installed imake is in your
- PATH.
-
- When needed, the imake variables XTop and MTop are normally set in your
- site.def (to {XTOP} amd {MTOP} respectively); however they may also be set
- with additional -D arguments to imake.
-
- 1. With both X and Motif in their source trees, ensure the imake variables
- XTop and MTop are set, and use:
-
- ${XTOP}/config/imake -I{MTOP}/config
-
- 2. With Motif in its source tree, and X installed, ensure MTop is set, and
- use:
-
- imake -I{MTOP}/config -DUseInstalled
-
- 3. With both Motif and X installed, and a nonstandard ProjectRoot (see
- site.def for an explanation of this), use:
-
- imake -DUseInstalled -DUseInstalledMotif -I{ProjectRoot}/lib/X11/config
-
- or, if the configuration files are in /usr/lib/X11/config:
-
- imake -DUseInstalled -DUseInstalledMotif
-
-
- To build a simple Imakefile, remember to include lines like this:
-
- LOCAL_LIBRARIES = XmClientLibs
- DEPLIBS = XmClientDepLibs
-
- Or, for a client that uses uil/mrm, replace these by MrmClientLibs and
- MrmClientDepLibs, and also use:
-
- MSimpleUilTarget(program)
-
- to build the client and uid file. Look at the demos for more examples.
-
-
- And Paul Howell <grue@engin.umich.edu> added:
-
- i did this, calling the new script "xmmkmf". It passes both -DUseInstalled
- and -DUseInstalledMotif.
-
- and i modified the stock R5 Imake.tmpl to do this:
-
- #include <Project.tmpl>
- #ifdef UseInstalledMotif
- #include <Motif.tmpl>
- #endif
-
- #include <Imake.rules>
- #ifdef UseInstalledMotif
- #include <Motif.rules>
- #endif
-
- the result was something that does both athena and motif rules. and it really
- works, just that easy!
-
-
- -----------------------------------------------------------------------------
- Subject: 169) How do I make context sensitive help? The Motif Style Guide
- says that an application must initiate context-sensitive help by changing the
- shape of the pointer to the question pointer. When the user moves the pointer
- to the component help is wanted on and presses BSelect, any available context
- sensitive help for the component must be presented, and the pointer reverts
- from the question pointer.
- [Last modified: August 92]
-
- Answer: A widget that gives context sensitive help would place this help in
- the XmNhelpCallback function. To trigger this function: (from Martin G C
- Davies, mgcd@se.alcbel.be)
-
- I use the following callback that is called when the "On Context" help
- pulldown menu is selected. It does the arrow bit and calls the help callbacks
- for the widget. It also zips up the widget tree looking for help if needs be.
- I don't restrict the arrows motion so I can get help on dialog boxes. No
- prizes for guessing what "popup_message" does.
-
-
- static void ContextHelp(
- Widget w ,
- Opaque * tag ,
- XmAnyCallbackStruct * callback_struct
- )
- {
- static Cursor context_cursor = NULL ;
- Widget context_widget ;
-
- if ( context_cursor == NULL )
- context_cursor = XCreateFontCursor( display, XC_question_arrow ) ;
-
- context_widget = XmTrackingLocate( top_level_widget,
- context_cursor, FALSE ) ;
-
- if ( context_widget != NULL ) /* otherwise its not a widget */
- {
- XmAnyCallbackStruct cb ;
-
- cb.reason = XmCR_HELP ;
- cb.event = callback_struct->event ;
-
- /*
- * If there's no help at this widget we'll track back
- up the hierarchy trying to find some.
- */
-
- do
- {
- if ( ( XtHasCallbacks( context_widget, XmNhelpCallback ) ==
- XtCallbackHasSome ) )
- {
- XtCallCallbacks( context_widget, XmNhelpCallback, & cb ) ;
- return ;
- }
- else
- context_widget = XtParent( context_widget ) ;
- } while ( context_widget != NULL ) ;
- }
-
- popup_message( "No context-sensitive help found\n\
- for the selected object." ) ;
- }
-
-
-
- Dave Bonnett suggested, to use the following translations for XmText (and
- XmTextField) widgets to get the same help with key strokes, and to provide an
- accelerator label in the Context help menu entry.
-
- MyApp*XmText*translations: #override\n\
- <Key>F1: Help()
-
- MyApp*Help_menu*Contextual Help.acceleratorText: F1
-
- MyApp*defaultVirtualBindings: osfBackSpace : <Key>Delete\n\
- osfRight : <Key>Right\n\
- osfLeft : <Key>Left\n\
- osfUp : <Key>Up\n\
- osfHelp : <Key>F1\n\
- osfDown : <Key>Down
-
-
- -----------------------------------------------------------------------------
- Subject: 170) How do I debug a modal interaction?
-
- When an application crashes in a modal section (such as in a modal dialog, a
- menu or when a drag and drop is in action), I cannot access the debugger.
-
- [Last modified: January 1993]
-
- Answer: Run the debugger on one display while the application writes to
- another display. ---------
- --------------------------------------------------------------------
- Subject: 171)+ How can I disable Drag and Drop in my Motif 1.2 client ?
-
- [Last modified: December]
-
- Answer: Set the XmDisplay drag-protocol resources to XmDRAG_NONE.
- The following code fragment demonstrates this:
-
- #include <Xm/Display.h>
-
-
- dw = XmGetXmDisplay(XtDisplay(shell));
- /* where "shell" is your client's top-level shell. */
-
- XtVaSetValues(dw, XmNdragInitiatorProtocolStyle, XmDRAG_NONE, NULL);
- XtVaSetValues(dw, XmNdragReceiverProtocolStyle, XmDRAG_NONE, NULL);
-
-
- thanks to Lance Purple (purple@austin.ibm.com)
-
- -----------------------------------------------------------------------------
- Subject: 172) Where can I get info on the Motif drag and drop protocol?
-
- [Last modified: March]
-
- Answer: The drag and drop protocol implemented by OSF is not stable, so they
- have not published it yet. The API should remain stable though. The OSF
- protocol is not compatable with the OpenLook protocol. OSF and Sun are
- working on a joint protocol for publication.
-
- For programming examples on Motif D&D, see the Motif 1.2 Programmers Guide.
-
- For a third alternative, try Roger Reynolds D&D protocol, available from
- netcom.com in /pub/rogerr.
-
- -----------------------------------------------------------------------------
- Subject: 173) TOPIC: ACKNOWLEDGEMENTS
-
- This list was compiled using questions and answers posed to
- comp.windows.x.motif and motif-talk. Some extracts were also taken from FAQs
- of comp.windows.x. To all who contributed one way or the other, thanks! I
- haven't often given individual references, but you may recognise
- contributions. If I have mangled them too much, let me know.
-
-
-
- +----------------------+---+
- Jan Newmarch, Information Science and Engineering,
- University of Canberra, PO Box 1, Belconnen, Act 2616
- Australia. Tel: (Aust) 6-2522422. Fax: (Aust) 6-2522999
-
- ACSnet: jan@ise.canberra.edu.au
- ARPA: jan%ise.canberra.edu.au@uunet.uu.net
- UUCP: {uunet,ukc}!munnari!ise.canberra.edu.au!jan
- JANET: jan%au.edu.canberra.ise@EAN-RELAY
-
-
- Jan Newmarch of has been maintaining this FAQ and has really helped a great
- many of us by providing this valuable service. He deserves a big round of
- applause for his efforts. I use this resource all the time and it has saved
- me countless hours with manual and source code trying to relearn what others
- have already discovered. Jan`s efforts are gratefully acknowledged here.
-
- I am maintaining the FAQ now and will strive to maintain the quality
- that Jan has acheived. Enjoy!
- Brian
-
- Brian Dealy - X Professional Organization
- dealy@kong.gsfc.nasa.gov
-
-
- (301) 572-8267
- (410) 799-7197 (FAX)
- +--------------------------+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- --
- ..........................
-
-